import { Person } from '@/store/reducer/user';
import request from '@/utils/request';
// console.log(request);

// 获取验证码接口
export const sendCode = (mobile: string) =>
  request({
    url: `/v1_0/sms/codes/${mobile}`,
    method: 'get',
  });

// 获取登录接口
export const login = ({ mobile, code }: { mobile: string; code: string }) =>
  request({
    url: '/v1_0/authorizations',
    method: 'post',
    data: {
      mobile,
      code,
    },
  });

// 获取用户自己信息接口
export const getUser = () =>
  request({
    url: '/v1_0/user',
  });

// 获取用户个人资料
export const getPersonData = () =>
  request({
    url: '/v1_0/user/profile',
  });

// 修改个人资料的上传图片
export const updatePhoto = (data: FormData) =>
  request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data,
  });

// 修改个人资料的性别/昵称/生日/简介
export const updatePartialData = (data: Partial<Person>) =>
  request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data,
  });

// 关注用户
export const userFollowAPI = (target: string) =>
  request({
    url: '/v1_0/user/followings',
    method: 'POST',
    data: { target },
  });

// 取消关注
export const cancelUserFollowAPI = (target: string) =>
  request({
    url: `/v1_0/user/followings/${target}`,
    method: 'DELETE',
  });
